// pages/home/home.js
let app = getApp();
var type = 0

Page({

    /**
     * 页面的初始数据
     */
    data: {
        my_daishenhe: 0,
        my_yield: 0,
        loadModal: true,
        my_img: [
            'http://image1.sansancloud.com/jianzhan/2017_11/08/21/34/34_242.jpg?x-oss-process=style/preview',
            'http://image1.sansancloud.com/jianzhan/2017_11/08/20/45/32_815.jpg?x-oss-process=style/preview',
            'http://image1.sansancloud.com/taoditongzhuang/2017_04/05/10/07/04_738.jpg?x-oss-process=style/preview',
            'http://image1.sansancloud.com/jianzhan/2017_11/08/20/44/32_860.jpg?x-oss-process=style/preview'
        ]
    },
    //版权所有
    bindviewbq: function () {
        wx.navigateTo({
            url: '../about/about',
        })
    },
    bindcl(e) {
        wx.navigateTo({
            url: '../msg_yield_add/msg_yield_add',
        })
    },
    bindviewzl(e) {
        wx.navigateTo({
            url: '../user_data/user_data?list=' + '1',
        })
    },
    bindviewgz(e) {
        wx.navigateTo({
            url: '../user_data/user_data?list=' + '2',
        })
    },
    bindviewsh(e) {
        wx.navigateTo({
            url: '../user_examine/user_examine',
        })
    },
    toprot() {
        // app.globalData.user_phone = ''
        wx.navigateTo({
            url: '../port/port',
        })
    },
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {

    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {
        let that = this
        this.setData({
            loadModal: false,
        })
        var date = new Date();
        var year = date.getFullYear();
        var month = date.getMonth() + 1;
        var day = date.getDate();
        let s = new Date(new Date().setDate(new Date().getDate() - 30)).toLocaleString().substring(0, 10).toLocaleString()

        var lw = new Date(date - 1000 * 60 * 60 * 24 * 30); //最后一个数字30可改，30天的意思
        var lastY = lw.getFullYear();
        var lastM = lw.getMonth() + 1;
        var lastD = lw.getDate();
        var startdate = lastY + "-" + (lastM < 10 ? "0" + lastM : lastM) + "-" + (lastD < 10 ? "0" + lastD : lastD); //三十天之前日期
        // console.log(startdate)
        if (month < 10) {
            month = "0" + month;
        }
        if (day < 10) {
            day = "0" + day;
        }
        var dateright = year + "-" + month + "-" + day;

        that.setData({
            dateright: dateright
        })
        that.setData({
            dateleft: startdate
        })
        wx.request({
            url: 'https://' + app.globalData.url + '/basicInfo/findAuditFormByCode',
            data: {
                lmobile: app.globalData.user_phone,
            },
            method: 'GET',
            dataType: 'json',
            responseType: 'text',
            header: {
                'content-type': 'application/json;charset=utf-8'
            },
            success: res => {
                if (res.data.status == 200) {
                    console.log(this.data.dateright)
                    if (res.data.data.obj != null) {
                        this.setData({
                            my_daishenhe: res.data.data.obj.length
                        })
                    }
                }
            },
            fail: function (res) {

            },
        })
    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {

    }
})